<?php
class AttachModel extends Model
{
	function parseAttach($options,$fileInfo)
	{
		$html = "";

		$insertFile = str_replace("./",$options["siteurl"]."/",$fileInfo["savepath"]).$fileInfo["savename"];
		$fileInfo["extension"] = strtolower($fileInfo["extension"]);
		switch($fileInfo["extension"])
		{
			case "jpg":
			case "jpeg":
			case "gif":
			case "png":
			case "bmp": $html = "<img src=".$insertFile." alt=".Input::forTag($fileInfo["remark"])." />";
				break;
			case "swf": $html = "<embed src=".$insertFile." type=application/x-shockwave-flash></embed>";
				break;
			case "wmv":
			case "mpeg":
			case "wav":
			case "wma":
			case "avi":
			case "mid":
			case "mp3": $html = "<embed src=".$insertFile." autostart=false loop=false></embed>";
				break;
			default: if(file_exists("./Public/Images/file/".$fileInfo["extension"].".gif")) {
					$fileImg = "<img src=".$options["siteurl"]."/Public/Images/file/".$fileInfo["extension"].".gif class=attachIcon />"; 
				}
				else
					$fileImg = "<img src=".$options["siteurl"]."/Public/Images/file/unknow.gif class=attachIcon />"; 
				$insertFile = $options["siteurl"]."/index.php?s=/Attach/".$fileInfo["id"];
				$html = $fileImg." <a href=".$insertFile." title=".Input::forTag($fileInfo["remark"])." target=_blank>".Input::forShow($fileInfo["remark"])."</a> 添加时间:".date("Y-m-d H:i:s",$fileInfo["uploadTime"])." 下载次数:".$fileInfo["downCount"];
				break;
		}

		return $html;
	}
}
?>